package com.poc.controller;

import com.poc.domain.Task;
import com.poc.dto.ResponseResult;
import com.poc.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/web")
public class WebController {

    @Autowired
    private TaskService taskService;

    @RequestMapping(value = "/task/{id}",method = RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    public ResponseResult launchTask(@PathVariable Integer id) {
        Task updateTask = taskService.launchTask(id);
        if (updateTask != null) {
            return ResponseResult.success(updateTask);
        } else {
            return ResponseResult.failure(null);
        }
    }
}
